package com.yzy.fly.mapper;

import com.yzy.fly.entity.role.FlyRequestMapping;
import com.yzy.fly.kernel.mapper.FlyBasicMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;


@Mapper
public interface FlyRequestMappingMapper extends FlyBasicMapper<FlyRequestMapping> {

    @Select("select * from fly_request_mapping a where 1=1")
    List<FlyRequestMapping> selectAll();

    @Select("select * from fly_request_mapping a where 1=1 and a.systemId = #{systemId}")
    List<FlyRequestMapping> selectAllBySystemId(@Param("systemId") int systemId);

    @Select("select * from fly_request_mapping a where 1=1 and a.controllerId = #{controllerId}")
    List<FlyRequestMapping> selectAllByControllerId(@Param("controllerId") int controllerId);

    @Select("select * from fly_request_mapping a where 1=1 and a.name = #{name}")
    FlyRequestMapping selectOneByName(@Param("name") String name);

    /**
     * 批量插入（mysql）
     * @param entityList
     * @return
     */
    Integer insertBatchSomeColumn(Collection<FlyRequestMapping> entityList);

    @Select("select * from fly_request_mapping a where systemId = #{systemId} order by a.packageName asc")
    List<FlyRequestMapping> selectAllPackageNameAsc(@Param("systemId") Integer systemId);

    @Delete("delete a from fly_request_mapping a where parentId = #{interfaceId}")
    int deleteAllByInterfaceId(@Param("interfaceId") Integer interfaceId);
}